package cn.raven.order.controller;

import cn.raven.order.service.IOrdetFailedCquisitionLogService;
import cn.raven.order.domain.OrdetFailedCquisitionLog;
import cn.raven.order.query.OrdetFailedCquisitionLogQuery;
import cn.raven.basic.utils.AjaxResult;
import cn.raven.basic.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/ordetFailedCquisitionLog")
public class OrdetFailedCquisitionLogController {
    @Autowired
    public IOrdetFailedCquisitionLogService ordetFailedCquisitionLogService;


    /**
     * 保存和修改公用的
     * @param ordetFailedCquisitionLog  传递的实体
     * @return Ajaxresult转换结果
     */
    @PutMapping
    //@PreAuthorize(name = "保存ordetFailedCquisitionLog",sn = "ordetFailedCquisitionLog:save")
    public AjaxResult save(@RequestBody OrdetFailedCquisitionLog ordetFailedCquisitionLog){
        try {
            if( ordetFailedCquisitionLog.getId()!=null)
                ordetFailedCquisitionLogService.update(ordetFailedCquisitionLog);
            else
                ordetFailedCquisitionLogService.add(ordetFailedCquisitionLog);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("保存对象失败！"+e.getMessage());
        }
    }
    /**
    * 删除对象信息
    * @param id
    * @return
    */
    @DeleteMapping(value="/{id}")
    //@PreAuthorize(name = "删除ordetFailedCquisitionLog",sn = "ordetFailedCquisitionLog:delete")
    public AjaxResult del(@PathVariable("id") Long id){
        try {
            ordetFailedCquisitionLogService.del(id);
            return AjaxResult.me();
        } catch (Exception e) {
        e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("删除对象失败！"+e.getMessage());
        }
    }
	
    //获取用户
    @GetMapping("/{id}")
    //@PreAuthorize(name = "id查询ordetFailedCquisitionLog",sn = "ordetFailedCquisitionLog:id")
    public OrdetFailedCquisitionLog findById(@PathVariable("id")Long id)
    {
        return ordetFailedCquisitionLogService.findOne(id);
    }


    /**
    * 查看所有的员工信息
    * @return
    */
    @GetMapping()
    public List<OrdetFailedCquisitionLog> findAll(){

        return ordetFailedCquisitionLogService.findAll();
    }


    /**
    * 分页查询数据
    *
    * @param query 查询对象
    * @return PageList 分页对象
    */
    @PostMapping("/list")
    //@PreAuthorize(name = "ordetFailedCquisitionLog列表",sn = "ordetFailedCquisitionLog:list")
    public PageList<OrdetFailedCquisitionLog> queryData(@RequestBody OrdetFailedCquisitionLogQuery query)
    {
        return ordetFailedCquisitionLogService.queryData(query);
    }
}
